#pragma once
#include <pthread.h>

namespace xjc
{
    class mutex
    {
    public:
        mutex(pthread_mutex_t *mutex) : _mutex(mutex)
        {
        }
        ~mutex()
        {
        }
        void lock()
        {
            pthread_mutex_lock(_mutex);
        }
        void unlock()
        {
            pthread_mutex_unlock(_mutex);
        }

    private:
        pthread_mutex_t *_mutex;
    };

    class lockGuard
    {
    public:
        lockGuard(pthread_mutex_t *mutex) : _mutex(mutex)
        {
            _mutex.lock();
        }
        ~lockGuard()
        {
            _mutex.unlock();
        }

    private:
        xjc::mutex _mutex;
    };
}